package com.gln.bloger.dao.impl;

import java.util.List;

import org.hibernate.Hibernate;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.gln.bloger.pojos.Comment;

public class TestCommentDaoImpl extends HibernateDaoSupport{
	@SuppressWarnings("unchecked")
	public List<Comment> loadAll(){
		List<Comment> comments = (List<Comment>)getHibernateTemplate().loadAll(Comment.class);
		for(Comment c: comments){
		    Hibernate.initialize(c.getEntry());
		    System.out.print(c);
		}
		return comments;
	}
	
	public Comment get(String id){
		Comment comment = (Comment)getHibernateTemplate().get(Comment.class, id);
		    System.out.print(comment);
		return comment;
	}

	public static void main(String [] args){
		ApplicationContext ctx=new  
		FileSystemXmlApplicationContext("webRoot/WEB-INF/config/spring/testbeans.xml");
	    TestCommentDaoImpl cdao = (TestCommentDaoImpl)ctx.getBean("testCommentDao");
	    @SuppressWarnings("unused")
		Comment comment = cdao.get("2c9083ad1a9a182d011a9a19175c0001");
//	    List<Comment> comments = cdao.loadAll();
	}
}
